{extend name='common@layout/seller' /}
{block name="left"}{include file='goods/left'}{/block}
{block name="breadcrumb"}
<div class="ncsc-path"><i class="icon-desktop"></i>商家管理中心<i class="icon-angle-right"></i>商品<i class="icon-angle-right"></i>商品管理</div>
{/block}
{block name='content'}
<script src="/old/data/resource/js/jquery.ajaxContent.pack.js?v1.2"></script>
<script src="/old/data/resource/js/jquery-ui/i18n/zh-CN.js?v1.2"></script>
<script src="/old/data/resource/js/common_select.js?v1.2"></script>
<script type="text/javascript" src="/old/data/resource/js/fileupload/jquery.iframe-transport.js?v1.2" charset="utf-8"></script>
<script type="text/javascript" src="/old/data/resource/js/fileupload/jquery.ui.widget.js?v1.2" charset="utf-8"></script>
<script type="text/javascript" src="/old/data/resource/js/fileupload/jquery.fileupload.js?v1.2" charset="utf-8"></script>
<script src="/old/data/resource/js/jquery.poshytip.min.js?v1.2"></script>
<script src="/old/data/resource/js/jquery.mousewheel.js?v1.2"></script>
<script type="text/javascript" src="/old/data/resource/js/jquery.charCount.js?v1.2"></script>
<!--[if lt IE 8]>
  <script src="/old/data/resource/js/json2.js?v1.2"></script>
<![endif]-->
<script src="/old/data/resource/js/idialog/jquery.idialog.js?v1.2"></script>
<link rel="stylesheet" type="text/css" href="/old/data/resource/js/idialog/theme/default/style.css?v1.2"  />
<script src="/old/shop/resource/js/store_goods_add.step2.js?v1.2"></script>
<link rel="stylesheet" type="text/css" href="/old/data/resource/js/jquery-ui/themes/ui-lightness/jquery.ui.css?v1.2"  />
<style type="text/css">
    #fixedNavBar { filter:progid:DXImageTransform.Microsoft.gradient(enabled='true',startColorstr='#CCFFFFFF', endColorstr='#CCFFFFFF');background:rgba(255,255,255,0.8); width: 90px; margin-left: 510px; border-radius: 4px; position: fixed; z-index: 999; top: 172px; left: 50%;}
    #fixedNavBar h3 { font-size: 12px; line-height: 24px; text-align: center; margin-top: 4px;}
    #fixedNavBar ul { width: 80px; margin: 0 auto 5px auto;}
    #fixedNavBar li { margin-top: 5px;}
    #fixedNavBar li a { font-family: Arial, Helvetica, sans-serif; font-size: 12px; line-height: 20px; background-color: #F5F5F5; color: #999; text-align: center; display: block;  height: 20px; border-radius: 10px;}
    #fixedNavBar li a:hover { color: #FFF; text-decoration: none; background-color: #27a9e3;}
</style>

<div id="fixedNavBar">
    <h3>页面导航</h3>
    <ul>
        <li><a id="demo1Btn" href="#demo1" class="demoBtn">基本信息</a></li>
        <li><a id="demo2Btn" href="#demo2" class="demoBtn">详情描述</a></li>
        <li><a id="demo4Btn" href="#demo4" class="demoBtn">物流运费</a></li>
        <li><a id="demo5Btn" href="#demo5" class="demoBtn">发票信息</a></li>
        <li><a id="demo6Btn" href="#demo6" class="demoBtn">其他信息</a></li>
    </ul>
</div>

{notpresent name='edit'}
{include file='goods/step'}
{else /}
<div class="tabmenu">
    <ul class="tab pngFix">
        <li class="{eq name='Think.config.action' value='modify'}active{else/}normal{/eq}"><a  href="{:url('seller/goods/modify?commonid='.input('commonid/d'))}">编辑商品</a></li>
        <li class="{eq name='Think.config.action' value='images'}active{else/}normal{/eq}"><a  href="{:url('seller/goods/images?id='.input('commonid/d'))}">编辑图片</a></li>
    </ul>
</div>
{/notpresent}

<div class="item-publish">
    <form method="post" id="goods_form" action="/?s=seller/goods/save">
        <input type="hidden" name="commonid" value="{$goods.id ?? ''}" />
        <div class="ncsc-form-goods">
            <h3 id="demo1">商品基本信息</h3>
            <dl>
                <dt>商品类目：</dt>
                <dd id="gcategory"> 
                    {$goods_class.tag_name}
                    <span></span>
                    <a class="ncsc-btn" href="/?s=seller/goods/cate&commonid={$goods.id ?? '0'}">编辑</a>
                    <input name="cate_id" value="{$goods_class.id}" type="hidden" />
                    <input type="hidden" name="cate_name" value="{$goods_class.tag_name}" class="text"/>
                </dd>
            </dl>
            <dl>
                <dt><i class="required">*</i>商品名称：</dt>
                <dd>
                    <input name="g_name" type="text" class="text w400" value="{$goods.goods_name ?? ''}" />
                    <span></span>
                    <p class="hint">商品标题名称长度至少3个字符，最长50个汉字</p>
                </dd>
            </dl>
            <dl>
                <dt>广告词：</dt>
                <dd>
                    <input name="g_jingle" type="text" class="text w400" value="{$goods.goods_jingle ?? ''}" />
                    <span></span>
                    <p class="hint">商品卖点最长不能超过140个汉字</p>
                </dd>
            </dl>
            <dl>
                <dt nc_type="no_spec"><i class="required">*</i>商品价格：</dt>
                <dd nc_type="no_spec">
                    <input name="g_price" value="{$goods.goods_price ?? ''}" type="text"  class="text w60" /><em class="add-on"><i class="icon-renminbi"></i></em> <span></span>
                    <p class="hint">价格必须是0.01~9999999之间的数字，且不能高于市场价。<br>
                        此价格为商品实际销售价格，如果商品存在规格，该价格显示最低价格。</p>
                </dd>
            </dl>
            <dl>
                <dt><i class="required">*</i>市场价：</dt>
                <dd>
                    <input name="g_marketprice" value="{$goods.goods_marketprice ?? ''}" type="text" class="text w60" /><em class="add-on"><i class="icon-renminbi"></i></em> <span></span>
                    <p class="hint">价格必须是0.01~9999999之间的数字，此价格仅为市场参考售价，请根据该实际情况认真填写。</p>
                </dd>
            </dl>
            <dl>
                <dt>成本价：</dt>
                <dd>
                    <input name="g_costprice" value="{$goods.goods_costprice ?? ''}" type="text" class="text w60" /><em class="add-on"><i class="icon-renminbi"></i></em> <span></span>
                    <p class="hint">价格必须是0.00~9999999之间的数字，此价格为商户对所销售的商品实际成本价格进行备注记录，非必填选项，不会在前台销售页面中显示。</p>
                </dd>
            </dl>
            <dl>
                <dt>商品单位：</dt>
                <dd>
                    <input name="g_unit" value="{$goods.goods_unit ?? ''}" type="text" class="text w60" /><span></span>
                    <p class="hint">商家自定义商品单位，不超过8个字符，例如  元/次</p>
                </dd>
            </dl>
            <dl>
                <dt>折扣：</dt>
                <dd>
                    <input name="g_discount" value="" type="text" class="text w60" readonly="readonly" style="background:#E7E7E7 none;" /><em class="add-on">%</em>
                    <p class="hint">根据销售价与市场价比例自动生成，不需要编辑。</p>
                </dd>
            </dl>
      <?php if(!empty($spec_list)){?>
      <?php $i = '0';?>
      <?php foreach ($spec_list as $k=>$val){?>
      <dl nc_type="spec_group_dl_<?php echo $i;?>" nctype="spec_group_dl" class="spec-bg" <?php if($k == '1' || $k == config('city_spec_id')){?>spec_img="t"<?php }?>>
        <dt>
        	<?php if( $k > 2){ ?>
        		<input style="display: none;" name="sp_name[<?php echo $k;?>]" type="text" class="text w60 tip2 tr" title="自定义规格类型名称，规格值名称最多不超过4个字" value="<?php if (isset($goods['spec_name'][$k])) { echo $goods['spec_name'][$k];} else {echo $val['name'];}?>" maxlength="4" nctype="spec_name" data-param="{id:<?php echo $k;?>,name:'<?php echo $val['name'];?>'}"/>
          		<?php if (isset($goods['spec_name'][$k])) { echo $goods['spec_name'][$k];} else {echo $val['name'];}?>
          <?php echo "：";?>
        	<?php }else{ ?>
        		<input style="display: none;" name="sp_name[<?php echo $k;?>]" type="text" class="text w60 tip2 tr" title="自定义规格类型名称，规格值名称最多不超过4个字" value="<?php if (isset($goods['spec_name'][$k])) { echo $goods['spec_name'][$k];} else {echo $val['name'];}?>" maxlength="4" nctype="spec_name" data-param="{id:<?php echo $k;?>,name:'<?php echo $val['name'];?>'}"/>
        		<?php if (isset($goods['spec_name'][$k])) { echo $goods['spec_name'][$k];} else {echo $val['name'];}?>： 
        	<?php }?>
          </dt>
        <dd <?php if($k == '1' || $k == config('city_spec_id')){?>nctype="sp_group_val"<?php }?>>
          <ul class="spec">
            <?php if(is_array($val['value'])){?>
            <?php foreach ($val['value'] as $v) {?>
            <li><span nctype="input_checkbox">
              <input type="checkbox" <?php if( $v['sp_status'] == 1){?> disabled="disabled" checked="checked"<?php } ?> value="<?php echo $v['sp_value_name'];?>" nc_type="<?php echo $v['sp_value_id'];?>" <?php if($k == '1' || $k == config('city_spec_id')){?>class="sp_val"<?php }?> name="sp_val[<?php echo $k;?>][<?php echo $v['sp_value_id']?>]">
              </span><span nctype="pv_name" data-k="<?php echo $k ;?>"><?php echo $v['sp_value_name'];?></span></li>
            <?php }?>
            <?php }?>
            <li data-param="{gc_id:<?php echo $goods_class['id'];?>,sp_id:<?php echo $k;?>,url:''}">
              <?php if( $k > 2 ){?>
              <!-- 	<div nctype="specAdd1"><a href="javascript:void(0);" class="ncsc-btn" nctype="specAdd"><i class="icon-plus"></i>添加规格值</a></div> -->
              	<?php } ?>
              <div nctype="specAdd2" style="display:none;">
                <input class="text w60" type="text" placeholder="规格值名称" maxlength="20">
                <a href="javascript:void(0);" nctype="specAddSubmit" class="ncsc-btn ncsc-btn-acidblue ml5 mr5">确认</a><a href="javascript:void(0);" nctype="specAddCancel" class="ncsc-btn ncsc-btn-orange">取消</a></div>
            </li>
          </ul>
          <?php if($edit_goods_sign && ($k == '1' || $k == config('city_spec_id'))){?>
          <p class="hint">添加或取消规格时，提交后请编辑图片以确保商品图片能够准确显示。</p>
          <?php }?>
        </dd>
      </dl>
      <?php $i++;?>
      <?php }?>
      <?php }?>
      <dl nc_type="spec_dl" class="spec-bg" style="display:none; overflow: visible;">
        <dt>库存配置：</dt>
        <dd class="spec-dd">
          <table border="0" cellpadding="0" cellspacing="0" class="spec_table">
            <thead>
              <?php if(is_array($spec_list) && !empty($spec_list)){?>
              <?php foreach ($spec_list as $k=>$val){?>
            <th nctype="spec_name_<?php echo $k;?>"><?php if (isset($goods['spec_name'][$k])) { echo $goods['spec_name'][$k];} else {echo $val['name'];}?></th>
              <?php }?>
              <?php }?>
              <th class="w90"><span class="red">*</span>市场价
                <div class="batch"><i class="icon-edit" title="批量操作"></i>
                  <div class="batch-input" style="display:none;">
                    <h6>批量设置价格：</h6>
                    <a href="javascript:void(0)" class="close">X</a>
                    <input name="" type="text" class="text price" />
                    <a href="javascript:void(0)" class="ncsc-btn-mini" data-type="marketprice">设置</a><span class="arrow"></span></div>
                </div></th>
              <th class="w90"><span class="red">*</span>价格
                <div class="batch"><i class="icon-edit" title="批量操作"></i>
                  <div class="batch-input" style="display:none;">
                    <h6>批量设置价格：</h6>
                    <a href="javascript:void(0)" class="close">X</a>
                    <input name="" type="text" class="text price" />
                    <a href="javascript:void(0)" class="ncsc-btn-mini" data-type="price">设置</a><span class="arrow"></span></div>
                </div></th>
              <th class="w60"><span class="red">*</span>库存
                <div class="batch"><i class="icon-edit" title="批量操作"></i>
                  <div class="batch-input" style="display:none;">
                    <h6>批量设置库存：</h6>
                    <a href="javascript:void(0)" class="close">X</a>
                    <input name="" type="text" class="text stock" />
                    <a href="javascript:void(0)" class="ncsc-btn-mini" data-type="stock">设置</a><span class="arrow"></span></div>
                </div></th>
              <th class="w70">预警值
                <div class="batch"><i class="icon-edit" title="批量操作"></i>
                  <div class="batch-input" style="display:none;">
                    <h6>批量设置预警值：</h6>
                    <a href="javascript:void(0)" class="close">X</a>
                    <input name="" type="text" class="text stock" />
                    <a href="javascript:void(0)" class="ncsc-btn-mini" data-type="alarm">设置</a><span class="arrow"></span></div>
                </div></th>
              <th class="w100">商品货号</th>
                </thead>
            <tbody nc_type="spec_table">
            </tbody>
          </table>
          <p class="hint">点击<i class="icon-edit"></i>可批量修改所在列的值。</p>
        </dd>
      </dl>
            <dl>
                <dt nc_type="no_spec"><i class="required">*</i>商品库存：</dt>
                <dd nc_type="no_spec">
                    <input name="g_storage" value="{$goods.goods_storage ?? ''}" type="text" class="text w60" />
                    <span></span>
                    <p class="hint">商铺库存数量必须为0~999999999之间的整数<br/>若启用了库存配置，则系统自动计算商品的总数，此处无需卖家填写</p>
                </dd>
            </dl>
            <dl>
                <dt>库存预警值：</dt>
                <dd>
                    <input name="g_alarm" value="{$goods.goods_storage_alarm ?? ''}" type="text" class="text w60" />
                    <span></span>
                    <p class="hint">设置最低库存预警值。当库存低于预警值时商家中心商品列表页库存列红字提醒。<br>
                        请填写0~255的数字，0为不预警。</p>
                </dd>
            </dl>
            <dl>
                <dt nc_type="no_spec">商家货号：</dt>
                <dd nc_type="no_spec">
                    <p>
                        <input name="g_serial" value="{$goods.goods_serial ?? ''}" type="text"  class="text"  />
                    </p>
                    <p class="hint">商家货号是指商家管理商品的编号，买家不可见<br/>最多可输入20个字符，支持输入中文、字母、数字、_、/、-和小数点</p>
                </dd>
            </dl>
            <dl>
                <dt><i class="required">*</i>商品图片：</dt>
                <dd>
                    <div class="ncsc-goods-default-pic">
                        <div class="goodspic-uplaod">
                            <div class="upload-thumb"> <img alt="商品图" nctype="goods_image" src="{$goods.goods_image_thumb ?? '/old/data/upload/shop/common/default_goods_image_240.gif'}"/> </div>
                            <input type="hidden" name="image_path" id="image_path" nctype="goods_image" value="{$goods.goods_image ?? ''}" />
                            <span></span>
                            <p class="hint">上传商品默认主图，如多规格值时将默认使用该图或分规格上传各规格主图；支持jpg、gif、png格式上传或从图片空间中选择，建议使用<font color="red">尺寸800x800像素以上、大小不超过1M的正方形图片</font>，上传后的图片将会自动保存在图片空间的默认分类中。</p>
                            <div class="handle">
                                <div class="ncsc-upload-btn"> <a href="javascript:void(0);"><span>
                                            <input type="file" hidefocus="true" size="1" class="input-file" name="goods_image" id="goods_image">
                                        </span>
                                        <p><i class="icon-upload-alt"></i>图片上传</p>
                                    </a> </div>
                                <a class="ncsc-btn mt5" nctype="show_image" href="/?s=seller/album/pic_list&item=goods&inajax=1"><i class="icon-picture"></i>从图片空间选择</a> 
                                <a href="javascript:void(0);" nctype="del_goods_demo" class="ncsc-btn mt5" style="display: none;"><i class="icon-circle-arrow-up"></i>关闭相册</a></div>
                        </div>
                    </div>
                    <div id="demo"></div>
                </dd>
            </dl>
            <h3 id="demo2">商品详情描述</h3>
            <dl>
                <dt>商品描述：</dt>
                <dd id="ncProductDetails">
                    <div class="tabs">
                        <ul class="ui-tabs-nav" jquery1239647486215="2">
                            <li class="ui-tabs-selected"><a href="#panel-1" jquery1239647486215="8"><i class="icon-desktop"></i> 电脑端</a></li>
                        </ul>
                        <div id="panel-1" class="ui-tabs-panel" jquery1239647486215="4">
                            <?php showUEditor('editor', $goods['goods_body'], '100%','480px','visibility:visible;');?>
                            <div class="hr8">
                                <div class="ncsc-upload-btn"> 
                                    <a href="javascript:void(0);">
                                        <span>
                                            <input type="file" hidefocus="true" size="1" class="input-file" name="add_album" id="add_album" multiple="multiple">
                                        </span>
                                        <p><i class="icon-upload-alt" data_type="0" nctype="add_album_i"></i>图片上传</p>
                                    </a> 
                                </div>
                                <a class="ncsc-btn mt5" nctype="show_desc" href="/?s=seller/album/pic_list&item=des&inajax=1"><i class="icon-picture"></i>插入相册图片</a> 
                                <a href="javascript:void(0);" nctype="del_desc" class="ncsc-btn mt5" style="display: none;"><i class=" icon-circle-arrow-up"></i>关闭相册</a>
                            </div>

                            <p id="des_demo"></p>
                        </div>
                    </div>
                </dd>
            </dl>
            <dl>
                <dt>关联版式：</dt>
                <dd> 
                    <span class="mr50">
                        <label>顶部版式</label>
                        <select name="plate_top">
                            <option>请选择</option>
                            {present name='plate.1'}
                            {foreach $plate[1] as $one}
                            <option value='{$one.plate_id}' {eq name='goods.plateid_top' value="$one['plate_id']"}selected="selected"{/eq}>{$one.plate_name}</option>
                            {/foreach}
                            {/present}
                        </select>
                    </span> 
                    <span class="mr50">
                        <label>底部版式</label>
                        <select name="plate_bottom">
                            <option>请选择</option>
                            {present name='plate.0'}
                            {foreach $plate[0] as $one}
                            <option value='{$one.plate_id}' {eq name='goods.plateid_bottom' value="$one['plate_id']"}selected="selected"{/eq}>{$one.plate_name}</option>
                            {/foreach}
                            {/present}
                        </select>
                    </span> 
                </dd>
            </dl>
            <h3 id="demo4">商品物流信息</h3>
            <dl>
                <dt>所在地：</dt>
                <dd>
                    <p id="region">
                        <select class="d_inline" id="province_id" name='province'></select>
                        <select class="d_inline" name="areacode" id="areacode"></select>
                    </p>
                </dd>
            </dl>
            <dl nctype="virtual_null" >
                <dt>运费：</dt>
                <dd>
                    <ul class="ncsc-form-radio-list">
                        <li>
                            <input id="freight_0" nctype="freight" name="freight" class="radio" type="radio" checked="checked" value="0">
                            <label for="freight_0">固定运费</label>
                            <div nctype="div_freight" >
                                <input id="g_freight" class="w50 text" nc_type='transport' type="text" value="{$goods.goods_freight}" name="g_freight"><em class="add-on"><i class="icon-renminbi"></i></em> </div>
                        </li>
                        <!-- to do 运费模板
                        <li>
                            <input id="freight_1" nctype="freight" name="freight" class="radio" type="radio"  value="1">
                            <label for="freight_1">使用运费模板</label>
                            <div nctype="div_freight" style="display: none;">
                                <input id="transport_id" type="hidden" value="" name="transport_id">
                                <input id="transport_title" type="hidden" value="" name="transport_title">
                                <span id="postageName" class="transport-name" ></span><a href="JavaScript:void(0);" onclick="window.open('index.php?act=store_transport&type=select')" class="ncsc-btn" id="postageButton"><i class="icon-truck"></i>选择运费模板</a> </div>
                        </li>
                        -->
                    </ul>
                    <p class="hint">运费设置为 0 元，前台商品将显示为免运费。</p>
                </dd>
            </dl>
            <h3 id="demo5" nctype="virtual_null" >发票信息</h3>
            <dl nctype="virtual_null" >
                <dt>是否开增值税发票：</dt>
                <dd>
                    <ul class="ncsc-form-radio-list">
                        <li>
                            <label>
                                <input name="g_vat" value="1" <?php if (!empty($goods) && $goods['goods_vat'] == 1) { ?>checked="checked" <?php } ?> type="radio" />
                                是</label>
                        </li>
                        <li>
                            <label>
                                <input name="g_vat" value="0" <?php if (empty($goods) || $goods['goods_vat'] == 0) { ?>checked="checked" <?php } ?>  type="radio"/>
                                否</label>
                        </li>
                    </ul>
                    <p class="hint"></p>
                </dd>
            </dl>
            <h3 id="demo6">其他信息</h3>
            <dl>
                <dt>本店分类：</dt>
                <dd><span class="new_add"><a href="javascript:void(0)" id="add_sgcategory" class="ncsc-btn">新增分类</a> </span>
                <?php if (!empty($store_class_goods)) { ?>
                <?php foreach ($store_class_goods as $v) { ?>
                <select name="sgcate_id[]" class="sgcategory">
                  <option value="0">请选择...</option>
                  <?php foreach ($store_goods_class as $val) { ?>
                  <option value="<?php echo $val['id']; ?>" <?php if ($v==$val['id']) { ?>selected="selected"<?php } ?>><?php echo $val['name']; ?></option>
                  <?php if (is_array($val['_child']) && count($val['_child'])>0){?>
                  <?php foreach ($val['_child'] as $child_val){?>
                  <option value="<?php echo $child_val['id']; ?>" <?php if ($v==$child_val['id']) { ?>selected="selected"<?php } ?>>&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $child_val['name']; ?></option>
                  <?php }?>
                  <?php }?>
                  <?php } ?>
                </select>
                <?php } ?>
                <?php } else { ?>
                <select name="sgcate_id[]" class="sgcategory">
                  <option value="0">请选择...</option>
                  <?php if (!empty($store_goods_class)){?>
                  <?php foreach ($store_goods_class as $val) { ?>
                  <option value="<?php echo $val['id']; ?>"><?php echo $val['name']; ?></option>
                  <?php if (is_array($val['_child']) && count($val['_child'])>0){?>
                  <?php foreach ($val['_child'] as $child_val){?>
                  <option value="<?php echo $child_val['id']; ?>">&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $child_val['name']; ?></option>
                  <?php }?>
                  <?php }?>
                  <?php } ?>
                  <?php } ?>
                </select>
                <?php } ?>
                <p class="hint">商品可以从属于店铺的多个分类之下，店铺分类可以由 "商家中心 -> 店铺 -> 店铺分类" 中自定义</p>
              </dd>
            </dl>
            <dl>
                <dt>商品发布：</dt>
                <dd>
                    <ul class="ncsc-form-radio-list">
                      <li>
                        <label>
                          <input name="g_state" value="1" type="radio" <?php if (empty($goods) || $goods['goods_state'] == 1 || $goods['goods_state'] == 10) {?>checked="checked"<?php }?> />
                          立即发布 </label>
                      </li>
                      <li>
                        <label>
                          <input name="g_state" value="0" type="radio" nctype="auto" />
                          发布时间 </label>
                        <input type="text" class="w80 text" name="starttime" disabled="disabled" style="background:#E7E7E7 none;" id="starttime" value="<?php echo date('Y-m-d');?>" />
                        <select disabled="disabled" style="background:#E7E7E7 none;" name="starttime_H" id="starttime_H">
                          <?php foreach ($hour_array as $val){?>
                          <option value="<?php echo $val;?>" <?php $sign_h = 0;if($val>=date('h') && $sign_h != 1){?>selected="selected"<?php $sign_H = 1;}?>><?php echo $val;?></option>
                          <?php }?>
                        </select>
                        时
                        <select disabled="disabled" style="background:#E7E7E7 none;" name="starttime_i" id="starttime_i">
                          <?php foreach ($minute_array as $val){?>
                          <option value="<?php echo $val;?>" <?php $sign_k = 0;if($val>=date('i') && $sign_k != 1){?>selected="selected"<?php $sign_k = 1;}?>><?php echo $val;?></option>
                          <?php }?>
                        </select>
                        分 </li>
                      <li>
                        <label>
                          <input name="g_state" value="0" type="radio" <?php if (!empty($goods) && $goods['goods_state'] == 0) {?>checked="checked"<?php }?> />
                          放入仓库 </label>
                      </li>
                    </ul>
                  </dd>
            </dl>
            <dl>
                <dt>商品推荐：</dt>
                <dd>
                    <ul class="ncsc-form-radio-list">
                        <li>
                            <label>
                                <input name="g_commend" value="1" <?php if (empty($goods) || $goods['goods_commend'] == 1) { ?>checked="checked" <?php } ?>  type="radio" />
                                是</label>
                        </li>
                        <li>
                            <label>
                                <input name="g_commend" value="0" <?php if (!empty($goods) && $goods['goods_commend'] == 0) { ?>checked="checked" <?php } ?> type="radio"/>
                                否</label>
                        </li>
                    </ul>
                    <p class="hint">被推荐的商品会显示在店铺首页</p>
                </dd>
            </dl>
        </div>
        <div class="bottom tc hr32">
            <label class="submit-border">
                <input type="submit" class="submit" value="{present name='edit'}提 交{else/}下一步，上传商品图片{/present}" />
            </label>
        </div>
    </form>
</div>
<script type="text/javascript">
    var DEFAULT_GOODS_IMAGE = "{$Think.config.url_base}old/data/upload/shop/common/default_goods_image_60.gif";
    var SHOP_RESOURCE_SITE_URL = "{$Think.config.url_base}old/shop/resource";
    $(function () {
        $(".tabs").tabs();
        $.validator.addMethod('checkPrice', function (value, element) {
            _g_price = parseFloat($('input[name="g_price"]').val());
            _g_marketprice = parseFloat($('input[name="g_marketprice"]').val());
            if (_g_price > _g_marketprice) {
                return false;
            } else {
                return true;
            }
        }, '<i class="icon-exclamation-sign"></i>商品价格不能高于市场价格');
        jQuery.validator.addMethod("checkFCodePrefix", function (value, element) {
            return this.optional(element) || /^[a-zA-Z]+$/.test(value);
        }, '<i class="icon-exclamation-sign"></i>请填写不多于5位的英文字母');
        $('#goods_form').validate({
            errorPlacement: function (error, element) {
                $(element).nextAll('span').append(error);
            },
            rules: {
                cate_id: {
                    required: true
                },
                g_name: {
                    required: true,
                    minlength: 3,
                    maxlength: 50
                },
                g_jingle: {
                    maxlength: 140
                },
                g_price: {
                    required: true,
                    number: true,
                    min: 0.01,
                    max: 9999999,
                    checkPrice: true
                },
                g_marketprice: {
                    required: true,
                    number: true,
                    min: 0.01,
                    max: 9999999
                },
                g_costprice: {
                    number: true,
                    min: 0.00,
                    max: 9999999
                },
                g_storage: {
                    required: true,
                    digits: true,
                    min: 0,
                    max: 999999999
                },
                image_path: {
                    required: true
                },
                g_vindate: {
                    required: function () {
                        if ($("#is_gv_1").prop("checked")) {
                            return true;
                        } else {
                            return false;
                        }
                    }
                },
                g_vlimit: {
                    required: function () {
                        if ($("#is_gv_1").prop("checked")) {
                            return true;
                        } else {
                            return false;
                        }
                    },
                    range: [1, 10]
                },
                g_fccount: {
                    required: function () {
                        if ($("#is_fc_1").prop("checked")) {
                            return true;
                        } else {
                            return false;
                        }
                    }, range: [1, 100]
                },
                g_fcprefix: {
                    required: function () {
                        if ($("#is_fc_1").prop("checked")) {
                            return true;
                        } else {
                            return false;
                        }
                    }, checkFCodePrefix: true,
                    rangelength: [3, 5]
                },
                g_saledate: {
                    required: function () {
                        if ($('#is_appoint_1').prop("checked")) {
                            return true;
                        } else {
                            return false;
                        }
                    }
                },
                g_deliverdate: {
                    required: function () {
                        if ($('#is_presell_1').prop("checked")) {
                            return true;
                        } else {
                            return false;
                        }
                    }
                }
            },
            messages: {
                cate_id: {
                    required: '<i class="icon-exclamation-sign"></i>请选择商品类目',
                },
                g_name: {
                    required: '<i class="icon-exclamation-sign"></i>商品名称不能为空',
                    minlength: '<i class="icon-exclamation-sign"></i>商品标题名称长度至少3个字符，最长50个汉字',
                    maxlength: '<i class="icon-exclamation-sign"></i>商品标题名称长度至少3个字符，最长50个汉字'
                },
                g_jingle: {
                    maxlength: '<i class="icon-exclamation-sign"></i>商品卖点不能超过140个字符'
                },
                g_price: {
                    required: '<i class="icon-exclamation-sign"></i>商品价格不能为空',
                    number: '<i class="icon-exclamation-sign"></i>商品价格只能是数字',
                    min: '<i class="icon-exclamation-sign"></i>商品价格必须是0.01~9999999之间的数字',
                    max: '<i class="icon-exclamation-sign"></i>商品价格必须是0.01~9999999之间的数字'
                },
                g_marketprice: {
                    required: '<i class="icon-exclamation-sign"></i>请填写市场价',
                    number: '<i class="icon-exclamation-sign"></i>请填写正确的价格',
                    min: '<i class="icon-exclamation-sign"></i>请填写0.01~9999999之间的数字',
                    max: '<i class="icon-exclamation-sign"></i>请填写0.01~9999999之间的数字'
                },
                g_costprice: {
                    number: '<i class="icon-exclamation-sign"></i>请填写正确的价格',
                    min: '<i class="icon-exclamation-sign"></i>请填写0.00~9999999之间的数字',
                    max: '<i class="icon-exclamation-sign"></i>请填写0.00~9999999之间的数字'
                },
                g_storage: {
                    required: '<i class="icon-exclamation-sign"></i>商品库存不能为空',
                    digits: '<i class="icon-exclamation-sign"></i>库存只能填写数字',
                    min: '<i class="icon-exclamation-sign"></i>商铺库存数量必须为0~999999999之间的整数',
                    max: '<i class="icon-exclamation-sign"></i>商铺库存数量必须为0~999999999之间的整数'
                },
                image_path: {
                    required: '<i class="icon-exclamation-sign"></i>请设置商品主图'
                },
                g_vindate: {
                    required: '<i class="icon-exclamation-sign"></i>请选择有效期'
                },
                g_vlimit: {
                    required: '<i class="icon-exclamation-sign"></i>请填写1~10之间的数字',
                    range: '<i class="icon-exclamation-sign"></i>请填写1~10之间的数字'
                },
                g_fccount: {
                    required: '<i class="icon-exclamation-sign"></i>请填写1~100之间的数字',
                    range: '<i class="icon-exclamation-sign"></i>请填写1~100之间的数字'
                },
                g_fcprefix: {
                    required: '<i class="icon-exclamation-sign"></i>请填写3~5位的英文字母',
                    rangelength: '<i class="icon-exclamation-sign"></i>请填写3~5位的英文字母'
                },
                g_saledate: {
                    required: '<i class="icon-exclamation-sign"></i>请选择有效期'
                },
                g_deliverdate: {
                    required: '<i class="icon-exclamation-sign"></i>请选择有效期'
                }
            }
        });
    });
    var spec_group_checked = [<?php for ($i=0; $i<$sign_i; $i++){if($i+1 == $sign_i){echo "''";}else{echo "'',";}}?>];
    var str = '';
var V = new Array();

<?php for ($i=0; $i<$sign_i; $i++){?>
var spec_group_checked_<?php echo $i;?> = new Array();
<?php }?>

$(function(){
	into_array();
	goods_stock_set();
	
	$('dl[nctype="spec_group_dl"]').on('click', 'span[nctype="input_checkbox"] > input[type="checkbox"]',function(){
		into_array();
		goods_stock_set();
	});

	$('input[type="submit"]').click(function(){
		$('input[data_type="price"]').each(function(){
			if($(this).val() == ''){
				$(this).val($('input[name="g_price"]').val());
			}
		});
		$('input[data_type="stock"]').each(function(){
			if($(this).val() == ''){
				$(this).val('0');
			}
		});
		$('input[data_type="alarm"]').each(function(){
			if($(this).val() == ''){
				$(this).val('0');
			}
		});
		if($('dl[nc_type="spec_dl"]').css('display') == 'none'){
			$('dl[nc_type="spec_dl"]').find('input').attr('disabled','disabled');
		}
	});
	
});

function into_array(){
<?php for ($i=0; $i<$sign_i; $i++){?>
		
		spec_group_checked_<?php echo $i;?> = new Array();	
		$('dl[nc_type="spec_group_dl_<?php echo $i;?>"]').find('input[type="checkbox"]:checked').each(function(){
			i = $(this).attr('nc_type');
			v = $(this).val();
			c = null;
			if ($(this).parents('dl:first').attr('spec_img') == 't') {
				c = 1;
			}
			spec_group_checked_<?php echo $i;?>[spec_group_checked_<?php echo $i;?>.length] = [v,i,c];
		});

		spec_group_checked[<?php echo $i;?>] = spec_group_checked_<?php echo $i;?>;

<?php }?>
}

function goods_stock_set(){
    if(spec_group_checked.length < 1) return;
    $('input[name="g_price"]').attr('readonly','readonly').css('background','#E7E7E7 none');
    $('input[name="g_storage"]').attr('readonly','readonly').css('background','#E7E7E7 none');

    $('dl[nc_type="spec_dl"]').show();
    str = '<tr>';
    <?php recursionSpec(0,$sign_i);?>
    if(str == '<tr>'){
        $('input[name="g_price"]').removeAttr('readonly').css('background','');
        $('input[name="g_storage"]').removeAttr('readonly').css('background','');
        $('dl[nc_type="spec_dl"]').hide();
    }else{
        $('tbody[nc_type="spec_table"]').empty().html(str)
            .find('input[nc_type]').each(function(){
                s = $(this).attr('nc_type');
                try{$(this).val(V[s]);}catch(ex){$(this).val('');};
                if ($(this).attr('data_type') == 'marketprice' && $(this).val() == '') {
                    $(this).val($('input[name="g_marketprice"]').val());
                }
                if ($(this).attr('data_type') == 'price' && $(this).val() == ''){
                    $(this).val($('input[name="g_price"]').val());
                }
                if ($(this).attr('data_type') == 'stock' && $(this).val() == ''){
                    $(this).val('0');
                }
                if ($(this).attr('data_type') == 'alarm' && $(this).val() == ''){
                    $(this).val('0');
                }
            }).end()
            .find('input[data_type="stock"]').change(function(){
                computeStock();    
            }).end()
            .find('input[data_type="price"]').change(function(){
                computePrice();     
            }).end()
            .find('input[nc_type]').change(function(){
                s = $(this).attr('nc_type');
                V[s] = $(this).val();
            });
    }
}

<?php 
/**
 * 
 * 
 *  生成需要的js循环。递归调用	PHP
 * 
 *  形式参考 （ 2个规格）
 *  $('input[type="checkbox"]').click(function(){
 *      str = '';
 *      for (var i=0; i<spec_group_checked[0].length; i++ ){
 *      td_1 = spec_group_checked[0][i];
 *          for (var j=0; j<spec_group_checked[1].length; j++){
 *              td_2 = spec_group_checked[1][j];
 *              str += '<tr><td>'+td_1[0]+'</td><td>'+td_2[0]+'</td><td><input type="text" /></td><td><input type="text" /></td><td><input type="text" /></td>';
 *          }
 *      }
 *      $('table[class="spec_table"] > tbody').empty().html(str);
 *  });
 */
function recursionSpec($len,$sign) {
    if($len < $sign){
        echo "for (var i_".$len."=0; i_".$len."<spec_group_checked[".$len."].length; i_".$len."++){td_".(intval($len)+1)." = spec_group_checked[".$len."][i_".$len."];\n";
        $len++;
        recursionSpec($len,$sign);
    }else{
        echo "var tmp_spec_td = new Array();\n";
        for($i=0; $i< $len; $i++){
            echo "tmp_spec_td[".($i)."] = td_".($i+1)."[1];\n";
        }
        echo "tmp_spec_td.sort(function(a,b){return a-b});\n";
        echo "var spec_bunch = 'i_';\n";
        for($i=0; $i< $len; $i++){
            echo "spec_bunch += tmp_spec_td[".($i)."];\n";
        }
        echo "str += '<input type=\"hidden\" name=\"spec['+spec_bunch+'][goods_id]\" nc_type=\"'+spec_bunch+'|id\" value=\"\" />';";
        for($i=0; $i< $len; $i++){
            echo "if (td_".($i+1)."[2] != null) { str += '<input type=\"hidden\" name=\"spec['+spec_bunch+'][color]\" value=\"'+td_".($i+1)."[1]+'\" />';}";
            echo "str +='<td><input type=\"hidden\" name=\"spec['+spec_bunch+'][sp_value]['+td_".($i+1)."[1]+']\" value=\"'+td_".($i+1)."[0]+'\" />'+td_".($i+1)."[0]+'</td>';\n";
        }
        echo "str +='<td><input class=\"text price\" type=\"text\" name=\"spec['+spec_bunch+'][marketprice]\" data_type=\"marketprice\" nc_type=\"'+spec_bunch+'|marketprice\" value=\"\" /><em class=\"add-on\"><i class=\"icon-renminbi\"></i></em></td><td><input class=\"text price\" type=\"text\" name=\"spec['+spec_bunch+'][price]\" data_type=\"price\" nc_type=\"'+spec_bunch+'|price\" value=\"\" /><em class=\"add-on\"><i class=\"icon-renminbi\"></i></em></td><td><input class=\"text stock\" type=\"text\" name=\"spec['+spec_bunch+'][stock]\" data_type=\"stock\" nc_type=\"'+spec_bunch+'|stock\" value=\"\" /></td><td><input class=\"text stock\" type=\"text\" name=\"spec['+spec_bunch+'][alarm]\" data_type=\"alarm\" nc_type=\"'+spec_bunch+'|alarm\" value=\"\" /></td><td><input class=\"text sku\" type=\"text\" name=\"spec['+spec_bunch+'][sku]\" nc_type=\"'+spec_bunch+'|sku\" value=\"\" /></td></tr>';\n";
        for($i=0; $i< $len; $i++){
            echo "}\n";
        }
    }
}

?>


<?php if (!empty($goods) && $_GET['class_id'] <= 0 && !empty($sp_value) && !empty($spec_checked) && !empty($spec_list)){?>
$(function(){
	var E_SP = new Array();
	var E_SPV = new Array();
	<?php
	$string = '';
	foreach ($spec_checked as $v) {
		$string .= "E_SP[".$v['id']."] = '".$v['name']."';";
	}
	echo $string;
	echo "\n";
	$string = '';
	foreach ($sp_value as $k=>$v) {
		$string .= "E_SPV['".$k."'] = '".$v."';";
	}
	echo $string;
	?>
	V = E_SPV;
	$('dl[nc_type="spec_dl"]').show();
	$('dl[nctype="spec_group_dl"]').find('input[type="checkbox"]').each(function(){
		$('input[name="g_price"]').attr('readonly','readonly').css('background','#E7E7E7 none');
		$('input[name="g_storage"]').attr('readonly','readonly').css('background','#E7E7E7 none');
		s = $(this).attr('nc_type');
		if (!(typeof(E_SP[s]) == 'undefined')){
			$(this).attr('checked',true);
			v = $(this).parents('li').find('span[nctype="pv_name"]');
			var pk = v.attr('data-k');
			change_img_name($(this));	
		}
	});

    into_array();	
    
    str = '<tr>';
    <?php recursionSpec(0,$sign_i);?>
    if(str == '<tr>'){
        $('dl[nc_type="spec_dl"]').hide();
        $('input[name="g_price"]').removeAttr('readonly').css('background','');
        $('input[name="g_storage"]').removeAttr('readonly').css('background','');
    }else{
        $('tbody[nc_type="spec_table"]').empty().html(str)
            .find('input[nc_type]').each(function(){
                s = $(this).attr('nc_type');
                try{$(this).val(E_SPV[s]);}catch(ex){$(this).val('');};
            }).end()
            .find('input[data_type="stock"]').change(function(){
                computeStock();    
            }).end()
            .find('input[data_type="price"]').change(function(){
                computePrice();     
            }).end()
            .find('input[type="text"]').change(function(){
                s = $(this).attr('nc_type');
                V[s] = $(this).val();
            });
    }
});
<?php }?>

</script> 
<script src="/old/shop/resource/js/scrolld.js?v1.2"></script>
<script type="text/javascript" src="/static/area/area.min.js?v=1.0"></script>
<script type="text/javascript">
    $(function () {
        WYArea.init(function () {
            WYArea.select({
                def:{$goods.areacode|default=0},     //初始化的地区编码
                col:'aid',
                level: 2, //联动级别
                prov: '#province_id', //省对象
                city: '#areacode', //市对象
            });
        });
    });
</script>
<script type="text/javascript">
    $("[id*='Btn']").stop(true).on('click', function (e) {
        e.preventDefault();
        $(this).scrolld();
    })
</script>
{/block}